﻿using FlowerShop.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL.Services
{
    public class Customers
    {
        private readonly Model1 _context;

        public Customers()
        {
            _context = new Model1();
        }

        // 获取所有客户信息
        public List<Tpeople> GetAllCustomers()
        {
            return _context.Tpeople.ToList();
        }

        // 根据 ID 获取客户信息
        public Tpeople GetCustomerById(int id)
        {
            return _context.Tpeople.FirstOrDefault(c => c.t_id == id);
        }

        // 更新客户信息
        public void UpdateCustomer(Tpeople customer)
        {
            var existingCustomer = _context.Tpeople.FirstOrDefault(c => c.t_id == customer.t_id);
            if (existingCustomer != null)
            {
                existingCustomer.t_name = customer.t_name;
                existingCustomer.t_mima = customer.t_mima;
                existingCustomer.email = customer.email;
                _context.SaveChanges();
            }
        }
       
    }
}
